<style scoped>
  .expand-row{
    margin-bottom: 16px;
  }
  .lyx-table-btn{
    margin-right: 5px;
    margin-bottom: 2px;
  }
</style>
<template>
  <div>
    <Button v-for="(item, index) in list" :key="index" @click="goRun(item.indexMol, item.data)"
    :type="item.type" :size="item.size" class="lyx-table-btn">{{item.name}}</Button>
  </div>
</template>
<script>
import { itemParamByOrderList } from '@/api/eventlist'
export default {
  data () {
    return {
      list: []
    }
  },
  props: {
    params: Object
  },
  mounted () {
    this.rowList()
  },
  watch: {
    // params (ret) {
    //   console.log(ret)
    // }
  },
  methods: {
    async rowList () {
      let params = this.params
      let temp = []
      // 先放功能按钮，后放要件信息按钮(只查看要件)
      temp.push({ type: 'info', size: 'small', indexMol: 1, data: params.row, name: '进度' })
      let action1 = JSON.parse(params.row.action || '{}')
      for (let key in action1) {
        // 收受分离暂时只加查看结果按钮
        if (action1[key].type === 'button' && action1[key].next_process_id === '-1') {
          temp.push({ type: 'success', size: 'small', indexMol: 2, data: params.row, name: action1[key].name })
        }
      }
      if (params.row.params && params.row.params !== '{}') {
        let paramResult = await itemParamByOrderList({ id: params.row.item_id, code: params.row.code })
        paramResult.data.data.forEach((element, index) => {
          if (element.write_type === 'images') {
            temp.push({ type: 'info', size: 'small', indexMol: 3, data: element.img_url, name: '查看' + element.name })
          }
        })
      }
      this.list = temp
    },
    // 展开栏中按钮功能 type：指定要显示的模态框内容，data，当前按钮携带的数据
    goRun (type, data) {
      this.$emit('breachRun', type, data)
    }
  }
}
</script>
